<%@page import="lib_model.Account.Account_warehouse"%>
<%@page import="lib_model.WareHouse.Warehouse"%>
<%@page import="lib_model.Account.Account"%>
<%@page import="lib_model.Factories.Factory"%>
<%@page import="lib_model.Orther.ReturnObj"%>
<%@page import="java.util.ArrayList"%>
<%@page import="lib_model.Account.Account_factory"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<jsp:include page="../templates/Admin.jsp"></jsp:include>
Manager Account WareHouse
<jsp:include page="../templates/Title.jsp"></jsp:include>
<link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.css" type="text/css" />
  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js"></script>
  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js"></script>
  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js"></script>
 
 
<script type="text/javascript">
	$(document).ready(function() {
		$("#createfac").hide();
		$("#btcreate").click(function() {
			$("#createfac").fadeIn();
		});
	});
</script>
<% Account ac = new Account();
   ArrayList<Account> lac = (ArrayList<Account>)ac.Select().ObjResult;
   String a = "";
   for(Account acs : lac){
	   a += acs.username + " ";
   }
%>
  <script>
  $(document).ready(function(){
    var data = "<%= a%>".split(" ");
$("#example").autocomplete(data);
  });
  </script>

<jsp:include page="../templates/StyleAd.jsp"></jsp:include>

<div class="body-center w960">
<h2 class="title-show">Manager Account Warehouse</h2>
<%
	Warehouse fa = new Warehouse();
	ArrayList<Warehouse> fas = (ArrayList<Warehouse>) fa.Select().ObjResult;
	for (Warehouse fs : fas) {
%>

<table class="tb">

	<thead><tr><th colspan="4">Warehouse : <font color="#FFA43E"><%= fs.name %></font></th></tr>
	
		<tr>
			<th align="left" width="20%">Account</th>
			<th align="left" width="20%">Role</th>
			<th align="left" width="20%">Date Create</th>
		</tr>

	</thead>
	<%
		Account_warehouse wh = new Account_warehouse();
			ReturnObj rs = wh.SelectByIDwarehouse(fs.id);
			ArrayList<Account_warehouse> arr = (ArrayList<Account_warehouse>) rs.ObjResult;
	%>
	<tbody>
		<%
			for (Account_warehouse fac : arr) {
		%>
		<tr>
			<td><b><%=fac.username_ref%></b></td>
			<td><%=fac.role%></td>
			<td><%=fac.date_create%></td>
		</tr>
		<%
		
			}
		%>
	</tbody>
</table>
<br><br>
<%
	}
%>
<%
 	if (request.getAttribute("Mes") != null) {
 %>
<h2><%=request.getAttribute("Mes")%></h2>
<%
	}
%>
<input type="button" id="btcreate" value="Add Account Warehouse" /> 
<form action="../account/AddAccountWarehouse" method="post">
<table class="tb" style="width: 300px;" id="createfac">
	<thead>
		<tr>
			<th align="left" width="20%"></th>
			<th align="left" width="20%"></th>
		</tr>
		<tr>
			<td>Account</td>
			<td><input id="example" type="text" name="txtAcc" /></td>
		</tr>
		<tr>
			<td>Factories</td>
			<td><select name="txtType">
				<%
					for (Warehouse fs : fas) {
				%>
				<Option value="<%=fs.id%>"><%=fs.name%></Option>
				<%
					}
				%>
			</select></td>
		</tr>
		<tr>
			<td>Role</td>
			<td><input type="text" name="txtRole" /></td>
		</tr>
		<tr align="center">
			<td colspan="2"><input type="submit" value="Add"></td>
		</tr>
	</thead>
</table>
</form>
</div>
<jsp:include page="../templates/Footer.jsp"></jsp:include>